package com.atguigu.gmall.realtime.util;

/**
 * @author caodan
 * @version 1.0
 * @date 2022-09-28 14:12
 * 获取mysql 连接器参数
 */
public class MysqlUtil {

    // 获取 mysql 连接器参数
    public static String getMysqlDDLStr() {
        return "CREATE TABLE base_dic (\n" +
                "  dic_code STRING,\n" +
                "  dic_name STRING,\n" +
                "  parent_code STRING,\n" +
                "  PRIMARY KEY (dic_code) NOT ENFORCED\n" +
                ") " + getMysqlPorps("base_dic");
    }

    /**
     * 获取 mysql 属性
     *
     * @param tableName 数据库名
     * @return sql条件
     */
    public static String getMysqlPorps(String tableName) {
        return "WITH (\n" +
                "   'connector' = 'jdbc',\n" +
                "   'url' = 'jdbc:mysql://hadoop102:3306/gmall',\n" +
                "   'table-name' = '" + tableName + "',\n" +
                "   'username' = 'root',\n" +
                "   'driver' = 'com.mysql.cj.jdbc.Driver',\n" +
                "   'password' = '000000',\n" +
                "   'lookup.cache.max-rows' = '400',\n" +
                "   'lookup.cache.ttl' = '10 second'\n" +
                ")";
    }
}
